package com.pearadmin.pro.modules.fnc.service.impl;

import java.util.List;
import java.util.ArrayList;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pearadmin.pro.common.web.base.page.PageResponse;
import com.pearadmin.pro.common.web.base.page.Pageable;

import com.pearadmin.pro.modules.fnc.domain.ScrmFncInfo;
import com.pearadmin.pro.modules.fnc.param.ScrmFncInfoRequest;
import com.pearadmin.pro.modules.fnc.repository.ScrmFncInfoRepository;
import com.pearadmin.pro.modules.fnc.service.ScrmFncInfoService;
import com.pearadmin.pro.modules.mkt.domain.MktActive;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;


/**
 * 财务-收支明细Service业务层处理
 *
 * @author ChenJIan
 * @date 2021-09-25
 */
@Service
public class ScrmFncInfoServiceImpl extends ServiceImpl<ScrmFncInfoRepository, ScrmFncInfo> implements ScrmFncInfoService
{
    @Resource
    private ScrmFncInfoRepository scrmFncInfoRepository;

    /**
     * 查询财务-收支明细
     * @param request
     * @return 财务-收支明细 分页集合
     * */
    @Override
    public PageResponse<ScrmFncInfo> page(ScrmFncInfoRequest request)
    {
        LambdaQueryWrapper<ScrmFncInfo> query = new LambdaQueryWrapper<ScrmFncInfo>();

        query.eq(ObjectUtil.isNotEmpty(request.getOrderSn()), ScrmFncInfo::getOrderSn, request.getOrderSn());
        query.eq(ObjectUtil.isNotEmpty(request.getTradeType()), ScrmFncInfo::getTradeType, request.getTradeType());
        query.eq(ObjectUtil.isNotEmpty(request.getPaymentMethod()), ScrmFncInfo::getPaymentMethod, request.getPaymentMethod());
        query.like(ObjectUtil.isNotEmpty(request.getProduceWay()), ScrmFncInfo::getProduceWay, request.getProduceWay());
        query.eq(ObjectUtil.isNotEmpty(request.getBillSrc()), ScrmFncInfo::getBillSrc, request.getBillSrc());
        query.eq(ObjectUtil.isNotEmpty(request.getCurrency()), ScrmFncInfo::getCurrency, request.getCurrency());
        query.gt(ObjectUtil.isNotEmpty(request.getBgeinTime()),  ScrmFncInfo::getCreateTime, request.getBgeinTime());
        query.lt(ObjectUtil.isNotEmpty(request.getEndTime()),  ScrmFncInfo::getCreateTime, request.getEndTime());
        return Pageable.of(request,(()->  scrmFncInfoRepository.selectList(query)));
    }
    /**
     * 保存财务-收支明细
     *
     * @param id 财务-收支明细ID
     * @return 财务-收支明细
     */
    @Override
    public boolean saveOrUpdate(ScrmFncInfo request) {
        return this.save(request);
    }

    /**
     * 查询财务-收支明细
     *
     * @param id 财务-收支明细ID
     * @return 财务-收支明细
     */
    @Override
    public ScrmFncInfo selectScrmFncInfoById(Long id)
    {
        return scrmFncInfoRepository.selectById(id);
    }

}
